<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Introduction to IronPython Mono Winforms</title>
<link rel="stylesheet" href="/cfg/format.css" type="text/css">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="keywords" content="GUI, Winforms, Mono, IronPython, introduction, programming, tutorial">
<meta name="description" content="Introduction to IronPython Mono Winforms">
<meta name="language" content="en">
<meta name="author" content="Jan Bodnar">
<meta name="distribution" content="global">

<script type="text/javascript" src="/lib/jquery.js"></script>
<script type="text/javascript" src="/lib/common.js"></script>

</head>

<body>

<div class="container">

<div id="wide_ad" class="ltow">
<script type="text/javascript"><!--
google_ad_client = "pub-9706709751191532";
/* 160x600, August 2011 */
google_ad_slot = "2484182563";
google_ad_width = 160;
google_ad_height = 600;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>

<div class="content">


<a href="/" title="Home">Home</a>&nbsp;
<a href=".." title="Home">Contents</a>


<h1>Introduction to IronPython Mono Winforms</h1>


<p>
The first part of the IronPython Mono Winforms tutorial introduces
the Mono platform and the Winforms library. 
</p>

<div class="center">
<script type="text/javascript"><!--
google_ad_client = "pub-9706709751191532";
/* horizontal */
google_ad_slot = "1734478269";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>

<h2>About this tutorial</h2>

<p>
This is Mono IronPython Winforms tutorial. Mono IronPython Winforms tutorial is for beginner programmers. 
The goal of this tutorial is to teach readers basics of GUI programming in Mono Winforms for the
IronPython programming language.
The tutorial is created and tested on Linux. Nevertheless, it can be used on other 
operating systems as well. Most examples should run without modification. 
Images used in this tutorial can be downloaded <a href="/img/gui/ironpython/images.tgz">here</a>.
</p>


<h2>Mono</h2>

<p>
The Mono Project is an open development initiative sponsored by <b>Novell</b> 
to develop an open source, UNIX version of the Microsoft .NET development platform.
It is a .NET compatible set of tools, which include C# compiler, Common Language Runtime,
ADO.NET, ASP.NET and Winforms libraries. 
</p>

<p>
Mono can be divided into three groups:
</p>

<ul>
<li>Core components</li>
<li>Gnome development stack</li>
<li>Microsoft compatibility stack</li>
</ul>

<p>
The core components are the C# language and the Common language runtime. 
The Gnome development stack includes the GTK# library and various database 
connectivity libraries. Finally, the Microsoft
compatibility stack includes the ADO.NET, ASP.NET and the Winforms libraries. 
</p>

<p>
Mono is multiplatform programming platform. It can be run on Linux, BSD, 
Mac OS X, Solaris and Windows operating systems. It is a multilanguage effort. 
For now, only C# language is fully supported. Languages like Visual Basic or IronPython
are not yet finished. They are still being developed.
</p>

<h2>Winforms</h2>

<p>
Windows Forms is a graphical user interface application programming interface (API)
included as a part of Microsoft's .NET Framework.
As of 13 May 2008, Mono's System.Windows.Forms 2.0 is API complete. 
Simply put, Winforms is a library for creating GUI applications. 
</p>

<h2>IronPython</h2>

<p>
IronPython is an implementation of the Python programming language 
for the .NET Framework and Mono.
IronPython is written entirely in C#. There are some significant differences
between Python and IronPython. 
</p>

<h2>Runnning code examples</h2>

<p>
Our tutorial uses IronPython language. 
</p>


<div class="codehead">simple.py</div>
<pre class="code">
#!/usr/bin/ipy

import clr

clr.AddReference("System.Windows.Forms")

from System.Windows.Forms import Application, Form

class IForm(Form):

    def __init__(self):
        self.Text = 'Simple'
        self.Width = 250
        self.Height = 200
        self.CenterToScreen()

Application.Run(IForm())
</pre>

<p>
This small code example shows a simple window on the screen. It uses the Winforms
library. It is coded in IronPython.
</p>

<pre class="explanation">
 #!/usr/bin/ipy
</pre>

<p>
This is the path to the IronPython interpreter. 
</p>

<pre>
 $ chmod +x simple.py
 $ ./simple.py
</pre>

<p>
We make the script executable and run it. 
</p>


<h2>Reference</h2>

<a href="http://www.mono-project.com">mono-project.com</a></li><br>
<a href="http://msdn.microsoft.com/en-us/library/bb966997.aspx">Winforms 2.0 on msdn.com</a><br>
<a href="http://wikipedia.org">wikipedia.org</a><br>


<hr class="btm">

<p>
This was an introduction to the Mono IronPython Winforms. 
</p>

<div class="center">
<script type="text/javascript"><!--
google_ad_client = "pub-9706709751191532";
/* horizontal */
google_ad_slot = "1734478269";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<br>


<div class="botNav, center">
<span class="botNavItem"><a href="/">Home</a></span> ‡ <span class="botNavItem"><a href="..">Contents</a></span> ‡ 
<span class="botNavItem"><a href="#">Top of Page</a></span>
</div>

<div class="footer">
<div class="signature">
<a href="/">ZetCode</a> last modified January 31, 2009  <span class="copyright">&copy; 2007 - 2012 Jan Bodnar</span>
</div>
</div>

</div> <!-- content -->

</div> <!-- container -->

</body>
</html>


